﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

using TPEngine;
using TPEngine.Controls;

namespace Josse.GameStates
{
    public class TitleScreen : BaseGameState
    {
        #region Field

        Texture2D background;
        LinkLabel startLabel;

        #endregion

        #region Constructor

        public TitleScreen(Game game, GameStateManager manager)
            : base(game, manager)
        {
        }

        #endregion

        #region XNA methods

        protected override void LoadContent()
        {
            ContentManager Content = GameRef.Content;

            background = Content.Load<Texture2D>(@"Backgrounds/bg2");

            base.LoadContent();

            startLabel = new LinkLabel();
            startLabel.Position = new Vector2(500, 600);
            startLabel.Text = "Press ENTER to begin";
            startLabel.Color = Color.White;
            startLabel.TabStop = true;
            startLabel.HasFocus = true;
            startLabel.Selected += new EventHandler(startLabel_Selected);

            ControlManager.Add(startLabel);
        }

        public override void Update(GameTime gameTime)
        {
            ControlManager.Update(gameTime);

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            GameRef.SpriteBatch.Begin();

            base.Draw(gameTime);

            GameRef.SpriteBatch.Draw(
                background,
                GameRef.ScreenRectangle,
                Color.White);

            ControlManager.Draw(GameRef.SpriteBatch);

            GameRef.SpriteBatch.End();
        }

        #endregion

        #region Events

        void startLabel_Selected(object sender, EventArgs e)
        {
            StateManager.PushState(GameRef.startMenuScreen);
            
        }

        #endregion
    }
}
